using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using DbDiff.DbDiffWinClient.Helper;

namespace DbDiff.DbDiffWinClient.Forms
{
	/// <summary>
	/// Summary description for frmCompareStatus.
	/// </summary>
	public class frmCompareStatus : System.Windows.Forms.Form
	{
		private bool _mustClose;

		private System.Windows.Forms.Button btnClose;
		private System.Windows.Forms.GroupBox grpMain;
		private System.Windows.Forms.GroupBox grpTitle;
		private System.Windows.Forms.Label lblTitle;
		private System.Windows.Forms.TextBox txtCompareInfo;
	
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmCompareStatus()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			_mustClose = true;
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		
		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.btnClose = new System.Windows.Forms.Button();
			this.grpMain = new System.Windows.Forms.GroupBox();
			this.txtCompareInfo = new System.Windows.Forms.TextBox();
			this.grpTitle = new System.Windows.Forms.GroupBox();
			this.lblTitle = new System.Windows.Forms.Label();
			this.grpMain.SuspendLayout();
			this.grpTitle.SuspendLayout();
			this.SuspendLayout();
			// 
			// btnClose
			// 
			this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
			this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnClose.Location = new System.Drawing.Point(432, 312);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new System.Drawing.Size(80, 23);
			this.btnClose.TabIndex = 0;
			this.btnClose.Text = "Close";
			// 
			// grpMain
			// 
			this.grpMain.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.grpMain.Controls.Add(this.txtCompareInfo);
			this.grpMain.Location = new System.Drawing.Point(8, 48);
			this.grpMain.Name = "grpMain";
			this.grpMain.Size = new System.Drawing.Size(504, 256);
			this.grpMain.TabIndex = 2;
			this.grpMain.TabStop = false;
			// 
			// txtCompareInfo
			// 
			this.txtCompareInfo.BackColor = System.Drawing.Color.White;
			this.txtCompareInfo.Dock = System.Windows.Forms.DockStyle.Fill;
			this.txtCompareInfo.Location = new System.Drawing.Point(3, 16);
			this.txtCompareInfo.Multiline = true;
			this.txtCompareInfo.Name = "txtCompareInfo";
			this.txtCompareInfo.ReadOnly = true;
			this.txtCompareInfo.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.txtCompareInfo.Size = new System.Drawing.Size(498, 237);
			this.txtCompareInfo.TabIndex = 0;
			this.txtCompareInfo.Text = "";
			// 
			// grpTitle
			// 
			this.grpTitle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.grpTitle.Controls.Add(this.lblTitle);
			this.grpTitle.Location = new System.Drawing.Point(8, 0);
			this.grpTitle.Name = "grpTitle";
			this.grpTitle.Size = new System.Drawing.Size(504, 48);
			this.grpTitle.TabIndex = 3;
			this.grpTitle.TabStop = false;
			// 
			// lblTitle
			// 
			this.lblTitle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.lblTitle.Location = new System.Drawing.Point(8, 8);
			this.lblTitle.Name = "lblTitle";
			this.lblTitle.Size = new System.Drawing.Size(488, 32);
			this.lblTitle.TabIndex = 0;
			this.lblTitle.Text = "TITLE";
			this.lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// frmCompareStatus
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.btnClose;
			this.ClientSize = new System.Drawing.Size(518, 342);
			this.Controls.Add(this.grpMain);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.grpTitle);
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.MinimumSize = new System.Drawing.Size(432, 248);
			this.Name = "frmCompareStatus";
			this.ShowInTaskbar = false;
			this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "Compare databases";
			this.Load += new System.EventHandler(this.frmCompareStatus_Load);
			this.grpMain.ResumeLayout(false);
			this.grpTitle.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
		
		public void Init(string title) 
		{
			lblTitle.Text = title;
			_mustClose = true;
		}
		public void Init(string title, bool mustClose) 
		{
			int diff;
			lblTitle.Text = title;
			_mustClose = mustClose;

			btnClose.Visible = _mustClose;
			
			if (! _mustClose)
			{
				diff = btnClose.Top + btnClose.Height - (grpMain.Top + grpMain.Height);
				grpMain.Height += diff;
			}
		}
		
		private void UpdateView() 
		{
		}

		public void HideForm() 
		{
			if (! _mustClose) 
				this.Hide();
		}

		private void frmCompareStatus_Load(object sender, System.EventArgs e)
		{
			UpdateView();
		}
		private void UpdateItem(string objectType, string objectName) 
		{
			string text = "Compare " + objectType + "." + objectName + Environment.NewLine;
			txtCompareInfo.AppendText(text);
		}
		private void UpdateItem(string info) 
		{
			string text = info + Environment.NewLine;
			txtCompareInfo.AppendText(text);
		}
		public void SetCompareStatus(string objectType, string objectName) 
		{
			UpdateItem(objectType, objectName);
		}
		public void SetCompareStatus(string info) 
		{
			UpdateItem(info);
		}
	}
}